package com.wsj.a.iconandtextdemo;

import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.wsj.a.iconandtextdemo.base.BaseActivity;
import com.wsj.a.iconandtextdemo.databinding.ActivityMainBinding;

public class MainActivity extends BaseActivity {
    private ActivityMainBinding mBinding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mBinding = DataBindingUtil.setContentView(this,R.layout.activity_main);
        mBinding.setTitle("主页");
        mBinding.setOnClick(this);
//        initRightTitle();
    }

    public void initRightTitle(){
        int padding = getResources().getDimensionPixelOffset(R.dimen.default_padding);
        TextView textView = new TextView(this);
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.MATCH_PARENT);
        textView.setLayoutParams(layoutParams);
        textView.setPadding(padding,0,padding,0);
        textView.setGravity(Gravity.CENTER);
        textView.setText("右侧标题");
        textView.setTextColor(getResources().getColor(R.color.toolbar_title_color));
        mBinding.includeBaseTitle.rightLayout.addView(textView);
    }

    /**
     * 跳转至跟图标相关的页面
     * @param view
     */
    public void toIconActivity(View view){
        Intent intent = new Intent(this,IconActivity.class);
        startActivity(intent);
    }

    /**
     * 跳转至跟文字相关的页面
     * @param view
     */
    public void toTextActivity(View view){
        Intent intent = new Intent(this,TextActivity.class);
        startActivity(intent);
    }
}
